package stool.singletonpattern.part3;

/**
 * @Author Felix YF Dong
 * @Date 2021/5/12
 * @Description 双重锁定
 */
public class Singleton
{
    private Singleton(){}

    private static Singleton singleton;

    public static Singleton getSingleton()
    {
        if (singleton == null)
        {
            synchronized (Singleton.class)
            {
                if (singleton == null)
                {
                    singleton = new Singleton();
                }
            }
        }
        return singleton;
    }
}

